<template>
    <div>
      <h1>管理员登录</h1>
      <table class="table">
        <thead>
            <tr>
                <td>管理员账号</td>
                <td>
                    <input type="text" v-model="data.name">
                </td>
            </tr>
             <tr>
                <td>密码</td>
                <td>
                    <input type="password" v-model="data.pos">
                </td>
            </tr>
             <tr>
              
                <td colspan="2">
                    <input type="button" value="登录"  @click="Login">
                </td>
            </tr>
        </thead>
      </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from "vue"
import axios from "axios";
import { useRouter } from "vue-router";
const router=useRouter()
const data=ref({
     "id": 0,
  "name": "",
  "pos": ""
})
const Login=()=>{
    axios.get("https://localhost:7162/api/User/Login",{params:data.value}).then(res=>{
        if(res.data.id>0){
            alert('添加成功');
            router.push("ShowMemberView");
        }
         if(res.data.id==-1){
            alert('账号不存在');
            return;
        }
         if(res.data.id==-2){
            alert('密码错误');
            return;
        }

    })
}
</script>

<style scoped>

</style>